from django.db import models

# Create your models here.


class BaseModel(models.Model):
    created = models.DateTimeField(auto_now_add=True)
    update = models.DateTimeField(auto_now=True)

    # 设置抽象类表，由于继承
    class Meta:
        abstract = True


class User(BaseModel):
    LEVEL_CHOICES = ((1, '普通用户'), (2, 'VIP用户'))
    username = models.CharField(max_length=30, unique=True)
    password = models.CharField(max_length=30)
    email = models.EmailField()
    phone = models.CharField(max_length=11)
    photo = models.ImageField(upload_to='static/upload', null=True)
    level = models.SmallIntegerField(choices=LEVEL_CHOICES, default=1)
    code = models.CharField('验证码', max_length=4, null=True)
    uuid = models.CharField(max_length=120, null=True)

    class Meta:
        db_table = 'users'
        verbose_name = '用户表'
